package com.schoolvisitors.common;

import lombok.Getter;

@Getter
public class ParseResult<T> {
    private final T data;
    private final String error;

    public ParseResult(T data, String error) {
        this.data = data;
        this.error = error;
    }
    public boolean isError(){
        return error != null;
    }

    public static <T> ParseResult<T> success(T data) {
        return new ParseResult<>(data, null);
    }

    public static <T> ParseResult<T> failure(String error) {
        return new ParseResult<>(null, error);
    }
}
